//
//  SetTableViewController.m
//  明和智能
//
//  Created by 李李善 on 2018/8/23.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "SetTableViewController.h"
#import "SetTableViewCell.h"
#import "MZLoginVC.h"
#import "AboutMeViewController.h"
@interface SetTableViewController ()

@end

@implementation SetTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    NSArray *arr = @[@{@"title":@"联系客服",@"detail":@""},
                     @{@"title":@"关于我们",@"detail":@""},
                     @{@"title":@"版本更新",@"detail":@"发现新版本"},
                     @{@"title":@"清楚缓存",@"detail":@"375M"},
                     @{@"title":@"修改密码",@"detail":@""},
                     ];

    [self.dataArr addObjectsFromArray:arr];
    [self.tableView reloadData];
    
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    view.backgroundColor = hexCOLOR(@"ECECEC");
    [self.tableView config:^(UITableView *tableView) {
        tableView.backgroundColor = [UIColor clearColor];
        [view addV:tableView];
    }];
    
    UIButton *button = ({
        UIButton *l  = [UIButton buttonWithType:UIButtonTypeCustom];
        [l setNormalTitle:@"退出登录"];
        l.backgroundColor = hexCOLOR(@"FD8F25");
        [l setNormalTitleColor:[UIColor whiteColor]];
        l.titleLabel.font = kSysFont(kFitW(12));
        [l addTarget:self action:@selector(onClickButton:)];
        [view addV:l];
        l;
    });
    
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        weakSelf.tableView.frame = CGRectMake(0, 0, size.width,size.height-kFitH(50));
        button.frame =  CGRectMake(kFitW(10),weakSelf.tableView.bottom, size.width-kFitW(20),kFitH(40));
    }];
    
}

-(void)onClickButton:(UIButton *)button
{

    [UIView transitionWithView:[UIApplication sharedApplication].keyWindow duration:1.f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
        BOOL oldState = [UIView areAnimationsEnabled];
        [UIView setAnimationsEnabled:NO];
        UIWindow *window = [UIViewController appWindow];
        
        window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[MZLoginVC new]];
        [UIView setAnimationsEnabled:oldState];
    } completion:^(BOOL finished) {
        
    }];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{[tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
            {
                
            }
            break;
        case 1:
        {
            AboutMeViewController *vc = [AboutMeViewController new];
            vc.title = @"关于我们";
            [self pushToVC:vc];
        }
            break;
        case 2:
        {
            
        }
            break;
        case 3:
        {
            
        }
            break;
            
        default:
            break;
    }
    
}

-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    return [MCCellInfo configForCellId:cell Class:[SetTableViewCell class] Height:kFitH(44) TableView:tableView CellStyle:(UITableViewCellStyleValue1)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
